package com.aletto.general_store.presenters;

import com.aletto.general_store.data.DataRepository;
import com.aletto.general_store.data.model.Goods;
import com.aletto.general_store.data.model.GoodsDetails;
import com.aletto.general_store.data.model.OrderScore;
import com.aletto.general_store.data.model.PageResponse;
import com.aletto.general_store.data.model.Response;
import com.aletto.general_store.presenters.core.SimplePageTemplate;
import com.aletto.general_store.ui.adapters.GoodsCommentAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.sisyphus.spinach.core.INetPageTask;
import com.sisyphus.spinach.core.model.IPageResponse;
import com.sisyphus.spinach.core.model.IResponse;
import com.sisyphus.spinach.network.presenters.NetPageTask;
import com.sisyphus.spinach.network.presenters.NetSingleTask;
import com.sisyphus.spinach.ui.configs.impl.DefaultPageTemplate;

import java.util.ArrayList;
import java.util.Arrays;

import androidx.recyclerview.widget.RecyclerView;
import io.reactivex.rxjava3.core.Observable;

public class CommentGoodsPageTemplate  extends SimplePageTemplate<OrderScore> {

    private final String id;

    public CommentGoodsPageTemplate(RecyclerView recyclerView, SmartRefreshLayout refreshLayout, String id) {
        super(recyclerView, refreshLayout);
        this.id = id;
    }

    @Override
    public BaseQuickAdapter<OrderScore, BaseViewHolder> adapter(RecyclerView recyclerView) {
        return new GoodsCommentAdapter();
    }

    @Override
    public INetPageTask.Presenter<OrderScore, INetPageTask.View<OrderScore>> presenter() {
        return new NetPageTask<>(){
            @Override
            public Observable<? extends IResponse<? extends IPageResponse<OrderScore>>> execute(int page) {
                return DataRepository.getInstance().getGoodsScoreList(id, page, PageResponse.SIZE);
            }
        };
    }

}
